def test_delete_from_s3(self):
        s3_client = Mock()

        model = SiteObject('/dir/abc', 'md5',
                           dir_prefix='/dir', site_prefix='site')
        model.delete_from_s3('test-bucket', s3_client)
        s3_client.delete_object.assert_called_once_with(
            Bucket='test-bucket',
            Key='site/abc')
    def test_s3_key(self):
        model = SiteObject('abc', 'md5', site_prefix='site')
        assert model.s3_key == 'site/abc'

        model = SiteObject('/dir/abc', 'md5',
                           dir_prefix='/dir', site_prefix='site')
        assert model.s3_key == 'site/abc'

        model = SiteObject('/not_dir/abc', 'md5',
                           dir_prefix='/dir', site_prefix='site')
        assert model.s3_key == 'site//not_dir/abc'
    def test_constructor(self):
        model = SiteObject(
            filename='boop',
            md5='md5',
            dir_prefix='dir_prefix',
            site_prefix='site_prefix',
        )
        assert model is not None

        # default params are used
        model = SiteObject(filename='boop2', md5='abc')
        assert model is not None
        assert model.dir_prefix == ''
        assert model.site_prefix == ''
 def test_upload_to_s3(self):
     model = SiteObject('abc', 'md5')
     # Base SiteObject should not have this method implemented
     # because it is specific to file and redirect objects
     with pytest.raises(NotImplementedError):
         model.upload_to_s3('bucket', None)