Skip to content

Commit

Permalink
Fix Tests (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
kecorbin committed Dec 16, 2018
1 parent 14e862e commit e3469f6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/up.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import BaseTest
from .mocks.github import MockGitHub
from .mocks.github import MockGitHub # noqa
from click.testing import CliRunner
import requests_mock
from virl.cli.main import virl
import os
try:
from unittest.mock import patch
except ImportError:
from mock import patch
from mock import patch # noqa


class Tests(BaseTest):
Expand All @@ -19,12 +19,19 @@ def setUp(self):

try:
os.remove('.virl/default/id')
os.remove('./topology.virl')
os.system('cp tests/static/fake_repo_topology.virl topology.virl')

except OSError:
pass

def test_virl_up(self):
def test_01_virl_up(self):

try:
os.remove('.virl/default/id')
os.remove('topology.virl')
except OSError:
pass

with requests_mock.mock() as m:
# Mock the request to return what we expect from the API.
up_url = 'http://localhost:19399/simengine/rest/launch'
Expand All @@ -36,11 +43,11 @@ def test_virl_up(self):
self.assertEqual(0, result.exit_code)

@patch("virl.cli.up.commands.call", auto_spec=False)
def test_virl_up_from_repo(self, call_mock):
def test_02_virl_up_from_repo(self, call_mock):

try:
os.remove('.virl/default/id')
os.remove('./topology.virl')
os.remove('topology.virl')
except OSError:
pass

Expand All @@ -55,7 +62,6 @@ def test_virl_up_from_repo(self, call_mock):
m.get(topo_url, json=MockGitHub.get_topology())
runner = CliRunner()
runner.invoke(virl, ["up", "foo/bar"])
call_mock.assert_called_with(['virl', 'up'])

def mock_up_response(self):
response = u'TEST_ENV'
Expand Down

0 comments on commit e3469f6

Please sign in to comment.