예제 #1
0
    def test_export_full(self, celery, session):
        now = util.utcnow()
        long_ago = now - timedelta(days=367)
        CellShardFactory.create_batch(10, radio=Radio.gsm)
        CellShardFactory(
            radio=Radio.gsm,
            created=long_ago,
            modified=long_ago,
            last_seen=long_ago.date(),
        )
        session.commit()
        pattern = re.compile(
            r"MLS-full-cell-export-\d+-\d+-\d+T000000\.csv\.gz")

        mock_conn = mock.MagicMock()
        mock_bucket = mock.MagicMock(name="bucket")
        mock_obj = mock.MagicMock()
        mock_conn.return_value.Bucket.return_value = mock_bucket
        mock_bucket.Object.return_value = mock_obj

        with mock.patch.object(boto3, "resource", mock_conn):
            cell_export_full(_bucket="bucket")

        s3_key = mock_bucket.Object.call_args[0][0]
        assert pattern.search(s3_key)

        tmp_file = mock_obj.upload_file.call_args[0][0]
        assert pattern.search(tmp_file)
예제 #2
0
    def test_export_full(self, celery, session):
        now = util.utcnow()
        long_ago = now - timedelta(days=367)
        CellShardFactory.create_batch(10, radio=Radio.gsm)
        CellShardFactory(
            radio=Radio.gsm, created=long_ago,
            modified=long_ago, last_seen=long_ago.date())
        session.commit()
        pattern = re.compile(
            r'MLS-full-cell-export-\d+-\d+-\d+T000000\.csv\.gz')

        mock_conn = mock.MagicMock()
        mock_bucket = mock.MagicMock(name='bucket')
        mock_obj = mock.MagicMock()
        mock_conn.return_value.Bucket.return_value = mock_bucket
        mock_bucket.Object.return_value = mock_obj

        with mock.patch.object(boto3, 'resource', mock_conn):
            cell_export_full(_bucket='bucket')

        s3_key = mock_bucket.Object.call_args[0][0]
        assert pattern.search(s3_key)

        tmp_file = mock_obj.upload_file.call_args[0][0]
        assert pattern.search(tmp_file)
예제 #3
0
    def test_export_full(self):
        CellFactory.create_batch(10, radio=Radio.gsm)
        self.session.commit()

        with mock_s3() as mock_key:
            cell_export_full(_bucket='localhost.bucket')
            pat = r'MLS-full-cell-export-\d+-\d+-\d+T000000\.csv\.gz'
            self.assertRegex(mock_key.key, pat)
            method = mock_key.set_contents_from_filename
            self.assertRegex(method.call_args[0][0], pat)
예제 #4
0
    def test_export_full(self):
        CellShardFactory.create_batch(10, radio=Radio.gsm)
        self.session.commit()

        with mock_s3() as mock_key:
            cell_export_full(_bucket='localhost.bucket')
            pat = r'MLS-full-cell-export-\d+-\d+-\d+T000000\.csv\.gz'
            self.assertRegex(mock_key.key, pat)
            method = mock_key.set_contents_from_filename
            self.assertRegex(method.call_args[0][0], pat)
예제 #5
0
    def test_export_full(self, celery, session):
        now = util.utcnow()
        long_ago = now - timedelta(days=367)
        CellShardFactory.create_batch(10, radio=Radio.gsm)
        CellShardFactory(
            radio=Radio.gsm, created=long_ago,
            modified=long_ago, last_seen=long_ago.date())
        session.commit()
        pattern = re.compile(
            r'MLS-full-cell-export-\d+-\d+-\d+T000000\.csv\.gz')

        with mock_s3() as mock_key:
            cell_export_full(_bucket='localhost.bucket')
            assert pattern.search(mock_key.key)
            method = mock_key.set_contents_from_filename
            assert pattern.search(method.call_args[0][0])