示例#1
0
    def test_app_a_upload(self):
        name = "random_name"
        manifest = "{\"slave\": \"__init__.py\"}"
        path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                            "fixtures/simple_app/simple_app.tar.gz")
        result = io.run_sync(app.Upload(self.storage, name, manifest,
                                        path).execute,
                             timeout=2)

        assert result == "Uploaded successfully", result
        result = io.run_sync(app.View(self.storage, name).execute, timeout=2)
        assert result == json.loads(manifest), result
示例#2
0
    def test_AppUploadAction(self):
        storage = mock()
        jsonEncoder = mock()
        packageEncoder = mock()
        action = app.Upload(storage, **{'name': 'AppName', 'manifest': 'm.json', 'package': 'p.tar.gz'})
        action.jsonEncoder = jsonEncoder
        action.packageEncoder = packageEncoder

        when(jsonEncoder).encode('m.json').thenReturn('-encodedJson-')
        when(packageEncoder).encode('p.tar.gz').thenReturn('-encodedTar-')
        when(storage).write('manifests', any(str), any(str), any(tuple)).thenReturn('Ok')
        when(storage).write('apps', any(str), any(str), any(tuple)).thenReturn('Ok')
        action.execute().get(timeout=0.1)

        verify(storage).write('manifests', 'AppName', '-encodedJson-', APPS_TAGS)
        verify(storage).write('apps', 'AppName', '-encodedTar-', APPS_TAGS)
示例#3
0
 def test_upload_no_manifest(self):
     app.Upload(self.storage, "appname", "", None, True)
示例#4
0
 def test_upload_no_appname(self):
     app.Upload(self.storage, "", "dummy_manifest", None, True)
示例#5
0
 def test_upload_no_manifest_no_package(self):
     app.Upload(self.storage, "appname", "dummy_manifest", None, False)