-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest_dist_command.py
More file actions
41 lines (31 loc) · 1.27 KB
/
test_dist_command.py
File metadata and controls
41 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from mock import Mock
from pyfakefs import fake_filesystem_unittest
from shellfoundry.commands.dist_command import DistCommandExecutor
class TestDistCommandExecutor(fake_filesystem_unittest.TestCase):
def setUp(self):
self.setUpPyfakefs()
def test_dependencies_downloaded(self):
# Arrange
self.fs.CreateFile('nut_shell/shell.yml', contents="""
shell:
name: nut_shell
author: Chuck Norris
email: chuck@hollywood.io
description: Save the world
version: 1.0.0
""")
os.chdir('nut_shell')
dependencies_packager = Mock()
command_executor = DistCommandExecutor(dependencies_packager)
# Act
command_executor.dist()
# Assert
self.assertTrue(dependencies_packager.save_offline_dependencies.called)
args = dependencies_packager.save_offline_dependencies.call_args[0]
self.assertEqual(args[0].split(os.path.sep)[-1], 'requirements.txt')
self.assertEqual(args[0].split(os.path.sep)[-2], 'src')
self.assertEqual(args[1].split(os.path.sep)[-1], 'offline_requirements')
self.assertEqual(args[1].split(os.path.sep)[-2], 'dist')
ls = os.listdir(os.path.dirname(args[1]))
self.assertEqual(ls[0], 'nut_shell_offline_requirements.zip')