"""Unit tests for orchard_pricing_tier_value model.""" from pricing.models import orchard_pricing_tier_value import pytest from tests.utils import db_operations @pytest.fixture def db_fixture(): """Drop and re-create all the SQLite tables and seed them.""" db_operations.create_tables() db_operations.seed_data() def test_get_orchard_price_value_by_tier_id(db_fixture): """Test that the price value can be retrieved by tier ID.""" result = orchard_pricing_tier_value.get_price_value_by_tier_id(1) assert result == 1599 def test_get_orchard_price_values_by_tier_id(db_fixture): """Test that the price value can be retrieved by tier ID.""" result = orchard_pricing_tier_value.get_price_values_by_tier_id([1, 2]) assert result == [1599, 1499] def test_get_album_price_cents_by_product_id_with_price(db_fixture): """Test that the a product's album price can be retrieved.""" result = orchard_pricing_tier_value.get_album_price_cents_by_product_id(4) assert result == 1499 def test_get_album_price_cents_by_product_id_with_no_price(db_fixture): """Test that None is returned if a product has no album price.""" result = orchard_pricing_tier_value.get_album_price_cents_by_product_id(1) assert result is None def test_get_track_price_cents_by_product_id_with_price(db_fixture): """Test that the a product's track price can be retrieved.""" result = orchard_pricing_tier_value.get_track_price_cents_by_product_id(4) assert result == 99 def test_get_track_price_cents_by_product_id_with_no_price(db_fixture): """Test that None is returned if a product has no track price.""" result = orchard_pricing_tier_value.get_track_price_cents_by_product_id(1) assert result is None def test_get_all_pricing_tier_values(db_fixture): """Test that all the pricing tier values can be retrieved.""" result = orchard_pricing_tier_value.get_all_pricing_tier_values() assert result.status == 200 result_pricing_values = result.message assert len(result_pricing_values['items']) == 3 result_pricing_value = result_pricing_values['items'][0] assert result_pricing_value['orchard_pricing_tier_id'] == \ db_operations.orchard_pricing_tier_value_data[0]['orchard_pricing_tier_id'] assert result_pricing_value['country_code'] == \ db_operations.orchard_pricing_tier_value_data[0]['country_code'] assert result_pricing_value['value_cents'] == \ db_operations.orchard_pricing_tier_value_data[0]['value_cents']