# <center><i class="fa fa-edit"></i> Smart Dispenser: `members_addtional_Card` Subfunction Trial Report </center>
###### tags: `Internship`
:::info
**Goal:**
- [x] Final changes to code
- [x] Report of all possible test case
**Resources:**
[PyQt](https://hackmd.io/Ibk_VuuWRXOjkION4wk3tg)
[newXinXingPyQtStructure](https://drive.google.com/drive/u/0/folders/1Ahr8zkZgUv8ujauLKGz1ZSzkZq0M9_mx)
[CodiMD](https://hackmd.io/c/codimd-documentation/%2F%40codimd%2Fextra-supported-syntax#Flow-Chart)
[冠辰參考的筆記](https://www.wongwonggoods.com/page/4/?s=pyqt&ct_post_type=post%3Apage&ct_product_price=1)
:::
---
:::spoiler **Expand Catalog**
[TOC]
:::
---
## Figures
*Figure 1. Open a new collection members_additional_card*

*Figure 2. Flowchart*

---
### Changes to Code
:::warning
Ended up making a count function in addition to the planned ones ([can be referenced here](https://hackmd.io/@tiffanycheng/ry3LHLn55))
:::
* A count function was added to count all occurrences of the user with the primary card ID in `members_addtional_card`.
* The design of `members_addtionl_card` (as seen in Figure 1) is that the first occurence of the student ID should have the `primaryCard` field equal to the `addtionalCard` field.
* Originally thought there would be a count function in `XinxingQt.py` since it is served to query and update the collection. However, it did not include one.
* The count function counts the number of occurences of the student ID in `members_addtional_card`.
* If it is zero, then I am able to add two inputs: the `primaryCard` == `addtionalCard` input and the input of the additional card.
* If it is greater than zero, I just have to add the latter input

**Main Code**
* The data returned from Membersdata function is a dictionary object and does not have access to the partition function.
* Therefore I first parsed the data as a string before partitioning.
* Also changed the substring from [0:9] to [0:10] to make sure all 10 integers from the ID are retrieved.
* if-else statement added in case it is the first time the user is inputing an addtional card. This way both inputs are added when count == 0. Otherwise only one ipnut is needed.

## Test Trials
### 0.1 Re-enter schoolID and Register as new user buttons
Re-enter schoolID:


Register as new user:


:::success
both pop-ups close after clicking ok
:::
### 0.2 Hit cancel on run

:::danger
System closed after hitting cancel.
:::
### 0.3 Hit cancel on addtional card input

:::danger
System closed after hitting cancel.
:::
### 1. ID input is > 8 digits



### 2. ID input is > 8 digits



### 3. ID input contains non digit values



### 4. ID input is 8 digits but *is not* in `members_data`


### 5. ID input is 8 digits and is in `members_data`. Do not want to input addtional card.




:::danger
Clicked no and system closed.
:::
### 6. ID input is 8 digits and is in `members_data`. Want to input addtional card.




:::success
Clicked yes
:::
### 6.1 ID input is > 10 digits



### 6.2 ID input is < 10 digits



### 6.2 ID input contains non digit values



### 6.3 ID input is 10 digits and is first time adding additional card



### 6.4 ID input is 10 digits but same as registered primary card



### 6.5 ID input is 10 digits but same as a registered additonal card



### 6.6 ID input is 10 digits but additional card is an unregistered user's card




