Fix functional tests

This commit is contained in:
Nathan Chapman 2022-11-01 18:07:54 -06:00
parent 9696af6b67
commit 6141468f21
4 changed files with 41 additions and 8 deletions

View File

@ -0,0 +1,19 @@
[{
"model": "core.shippingrate",
"pk": 1,
"fields": {
"shipping_provider": "USPS",
"name": "Variable",
"container": "VARIABLE",
"min_order_weight": null,
"max_order_weight": null,
"is_selectable": false
}
}, {
"model": "core.sitesettings",
"pk": 1,
"fields": {
"usps_user_id": "012BETTE1249",
"default_shipping_rate": 1
}
}]

View File

@ -12,7 +12,7 @@ from django.contrib.staticfiles.testing import StaticLiveServerTestCase
class AddressTests(StaticLiveServerTestCase): class AddressTests(StaticLiveServerTestCase):
fixtures = ['products.json'] fixtures = ['shipping_rates.json', 'products.json']
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):

View File

@ -19,7 +19,9 @@ logger = logging.getLogger(__name__)
class CouponTests(StaticLiveServerTestCase): class CouponTests(StaticLiveServerTestCase):
fixtures = ['products.json', 'accounts.json', 'coupons.json'] fixtures = [
'shipping_rates.json', 'products.json', 'accounts.json', 'coupons.json'
]
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@ -87,7 +89,8 @@ class CouponTests(StaticLiveServerTestCase):
state_select.select_by_value('UT') state_select.select_by_value('UT')
postal_code_input = self.browser.find_element(By.NAME, 'postal_code') postal_code_input = self.browser.find_element(By.NAME, 'postal_code')
postal_code_input.send_keys('84321') postal_code_input.send_keys('84321')
self.browser.find_element(By.XPATH, self.browser.find_element(
By.XPATH,
'//input[@value="Continue"]' '//input[@value="Continue"]'
).click() ).click()
@ -106,7 +109,8 @@ class CouponTests(StaticLiveServerTestCase):
def test_apply_used_coupon_to_order_returns_message(self): def test_apply_used_coupon_to_order_returns_message(self):
# Add item to cart # Add item to cart
self.browser.get(self.live_server_url + '/products/1/') self.browser.get(self.live_server_url + '/products/1/')
self.browser.find_element(By.XPATH, self.browser.find_element(
By.XPATH,
'//input[@value="Add to cart"]' '//input[@value="Add to cart"]'
).click() ).click()
self.assertEqual( self.assertEqual(
@ -118,7 +122,8 @@ class CouponTests(StaticLiveServerTestCase):
coupon_input = self.browser.find_element(By.ID, 'id_code') coupon_input = self.browser.find_element(By.ID, 'id_code')
coupon_input.send_keys('MAY2022') coupon_input.send_keys('MAY2022')
self.browser.find_element(By.XPATH, '//input[@value="Apply"]').click() self.browser.find_element(By.XPATH, '//input[@value="Apply"]').click()
self.browser.find_element(By.XPATH, self.browser.find_element(
By.XPATH,
'//a[contains(text(), "Proceed to Checkout")]' '//a[contains(text(), "Proceed to Checkout")]'
).click() ).click()

View File

@ -99,6 +99,15 @@ WSGI_APPLICATION = 'ptcoffee.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
if DEBUG:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'django',
'NAME': 'ptcoffee_dev',
},
}
else:
DATABASES = { DATABASES = {
'default': DATABASE_CONFIG 'default': DATABASE_CONFIG
} }