Example #1
0
    def test_upload_with_login(self):
        if os.getenv('TEST_USER_PASSWORD', None) is None:
            self.useFixture(fixture_setup.FakeStore())
        else:
            self.useFixture(fixture_setup.StagingStore())

        # Make a snap
        project_dir = 'basic'
        self.addCleanup(self.logout)
        self.login()

        # Change to a random version.
        # The maximum size is 32 chars.
        new_version = str(uuid.uuid4().int)[:32]
        project_dir = self._update_version(project_dir, new_version)

        self.run_snapcraft('snap', project_dir)

        # Upload the snap
        snap_file_path = 'basic_{}_{}.snap'.format(new_version, self.deb_arch)
        self.assertThat(os.path.join(project_dir, snap_file_path),
                        FileExists())

        output = self.run_snapcraft(['upload', snap_file_path], project_dir)
        self.assertIn('Application uploaded successfully (as revision ',
                      output)
        self.assertIn('Please check out the application at: ', output)
Example #2
0
    def test_push_and_release(self):
        if not os.getenv('TEST_USER_PASSWORD', None):
            self.useFixture(fixture_setup.FakeStore())
        else:
            self.useFixture(fixture_setup.StagingStore())

        # Make a snap
        project_dir = 'basic'
        self.addCleanup(self.logout)
        self.login()

        # Change to a random name and version.
        unique_id = uuid.uuid4().int
        new_name = 'u1test-{}'.format(unique_id)
        # The maximum size is 32 chars.
        new_version = str(unique_id)[:32]

        project_dir = self.update_name_and_version(project_dir, new_name,
                                                   new_version)

        self.run_snapcraft('snap', project_dir)

        # Register the snap
        self.register(new_name)
        # Upload the snap
        snap_file_path = '{}_{}_{}.snap'.format(new_name, new_version, 'all')
        self.assertThat(os.path.join(project_dir, snap_file_path),
                        FileExists())

        output = self.run_snapcraft(
            ['push', snap_file_path, '--release', 'edge'], project_dir)
        expected = r'.*Ready to release!.*'.format(new_name)
        self.assertThat(output, MatchesRegex(expected, flags=re.DOTALL))
        expected = r'.*The \'edge\' channel is now open.*'
        self.assertThat(output, MatchesRegex(expected, flags=re.DOTALL))
Example #3
0
 def setUp(self):
     super().setUp()
     if not os.getenv('TEST_USER_PASSWORD', None):
         self.useFixture(fixture_setup.FakeStore())
     else:
         self.skipTest('There is no ubuntu-core snap in the staging server')
         # TODO add the snap to the staging server.
     self.login()
Example #4
0
 def setUp(self):
     super().setUp()
     if not os.getenv('TEST_USER_PASSWORD', None):
         self.useFixture(fixture_setup.FakeStore())
         self.reserved_name = 'test-reserved-snap-name'
     else:
         self.useFixture(fixture_setup.StagingStore())
         self.reserved_name = 'bash'
Example #5
0
 def setUp(self):
     super().setUp()
     self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
     self.snap_path = os.path.join(os.path.dirname(tests.__file__), 'data',
                                   'test-snap.snap')
     patcher = mock.patch('snapcraft.storeapi._upload.ProgressBar',
                          new=SilentProgressBar)
     patcher.start()
     self.addCleanup(patcher.stop)
Example #6
0
 def setUp(self):
     super().setUp()
     self.fake_store = self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
     self.snap_path = os.path.join(os.path.dirname(tests.__file__), 'data',
                                   'test-snap.snap')
     # These should eventually converge to the same module
     pbars = (
         'snapcraft.storeapi._upload.ProgressBar',
         'snapcraft.storeapi.ProgressBar',
     )
     for pbar in pbars:
         patcher = mock.patch(pbar, new=tests.SilentProgressBar)
         patcher.start()
         self.addCleanup(patcher.stop)
 def setUp(self):
     super().setUp()
     self.fake_store = self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
     self.expected = {
         'channel_map_tree': {
             'latest': {
                 '16': {
                     'i386': [
                         {
                             'info': 'none',
                             'channel': 'stable'
                         },
                         {
                             'info': 'none',
                             'channel': 'beta'
                         },
                         {
                             'info': 'specific',
                             'version': '1.0-i386',
                             'channel': 'edge',
                             'revision': 3
                         },
                     ],
                     'amd64': [
                         {
                             'info': 'specific',
                             'version': '1.0-amd64',
                             'channel': 'stable',
                             'revision': 2
                         },
                         {
                             'info': 'specific',
                             'version': '1.1-amd64',
                             'channel': 'beta',
                             'revision': 4
                         },
                         {
                             'info': 'tracking',
                             'channel': 'edge'
                         },
                     ],
                 }
             }
         }
     }
Example #8
0
 def setUp(self):
     super().setUp()
     self.fake_store = self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
     self.expected = [{
         'series': ['16'],
         'channels': [],
         'version': '2.0.1',
         'timestamp': '2016-09-27T19:23:40Z',
         'current_channels': ['beta', 'edge'],
         'arch': 'i386',
         'revision': 2
     }, {
         'series': ['16'],
         'channels': ['stable', 'edge'],
         'version': '2.0.2',
         'timestamp': '2016-09-27T18:38:43Z',
         'current_channels': ['stable', 'candidate', 'beta'],
         'arch': 'amd64',
         'revision': 1,
     }]
Example #9
0
 def setUp(self):
     super().setUp()
     self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
Example #10
0
 def setUp(self):
     super().setUp()
     self.fake_logger = fixtures.FakeLogger(level=logging.DEBUG)
     self.useFixture(self.fake_logger)
     self.fake_store = self.useFixture(fixture_setup.FakeStore())
     self.client = storeapi.StoreClient()
Example #11
0
 def setUp(self):
     super().setUp()
     if os.getenv('TEST_USER_PASSWORD', None) is None:
         self.useFixture(fixture_setup.FakeStore())
     else:
         self.useFixture(fixture_setup.StagingStore())